import request from './request.ts'

const Api = {
  // 增加点赞
  addGood(article_id: number, newGood: number) {
    return request<any, any>({
      url: `/good`,
      method: 'put',
      data: { article_id, newGood },
    })
  },
  // 增加浏览量
  addViews(article_id: number, newViews: number) {
    return request<any, any>({
      url: `/views`,
      method: 'put',
      data: { article_id, newViews },
    })
  },

  // 通过id获取文章数据
  getArticleDetail(article_id: number) {
    return request<any, any>({
      url: `/articleDetail`,
      method: 'get',
      params: { article_id },
    })
  },

  //获取文章数据
  getArticle(
    page: number,
    pagesize: number,
    category_id: number,
    tag_id: number
  ) {
    return request<any, any>({
      url: `/article`,
      method: 'get',
      params: { page, pagesize, category_id, tag_id },
    })
  },

  // 获取分类数据
  getCategory() {
    return request<any, any>({
      url: `/category`,
      method: 'get',
    })
  },

  // 获取标签数据
  getTag() {
    return request<any, any>({
      url: `/tag`,
      method: 'get',
    })
  },
}

export default Api

export interface ArticleDetail {
  title: string
  content: string
  views: number
  good_count: number
}
